package com.atguigu.mvc.handler;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TargetHandler {

    @RequestMapping("/exception/arithmetic")
    public String throwArithmeticExceptionHandler() {

        System.out.println(10 / 0);

        return "target";
    }

    @RequestMapping("/exception/null/pointer")
    public String throwNullPointer() {

        String s = null;

        System.out.println(s.length());

        return "target";
    }

    @ResponseBody
    @RequestMapping("/exception/array/out/of/bound/ajax")
    public String throwArrayOutOfBoundAjax() {

        int[] arr = new int[10];
        System.out.println(arr[15]);

        return "Ajax响应";
    }

    @RequestMapping("/exception/array/out/of/bound/common")
    public String throwArrayOutOfBoundCommon() {

        int[] arr = new int[10];
        System.out.println(arr[15]);

        return "target";
    }
}
